// Main.cs created with MonoDevelop
// User: kenw at 8:55 AM 5/6/2008
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;

using Gtk;
using Glade;

namespace QDG.Powerball
{
	class Powerball
	{
		private R250 rnd = null;
		private int timesPlayed = 0;
		private int costPerPlay = 0;

		private GUI gui;
   
		
		
		// for a powerball only win - worth $3
		public int UpdatePB(GUI g, Values v)
		{
			v.PBResult[Values.Times]++;
			v.PBResult[Values.Amount] += 3;
			Application.Invoke(delegate {g.PBWins = v.PBResult[Values.Times];
				g.PBAmount = v.PBResult[Values.Amount];});
			Console.WriteLine("UpdatePB {0} {1}", v.PBResult[Values.Times], v.PBResult[Values.Amount]);

			return 3;
		}
		
		// powerball + 1 ball, $4
		public int UpdatePB1(GUI g, Values v)
		{
			v.PB1Result[Values.Times]++;
			v.PB1Result[Values.Amount] += 4;
			Application.Invoke(delegate {g.PB1Wins = v.PB1Result[Values.Times];
				g.PB1Amount = v.PB1Result[Values.Amount];});

			Console.WriteLine("UpdatePB1 {0} {1}", v.PB1Result[Values.Times], v.PB1Result[Values.Amount]);

			return 4;
		}
		
		
		// powerball + 2 balls, $7
		public int UpdatePB2(GUI g, Values v)
		{
			v.PB2Result[Values.Times]++;
			v.PB2Result[Values.Amount] += 7;
			Application.Invoke(delegate {g.PB2Wins = v.PB2Result[Values.Times];
				g.PB2Amount = v.PB2Result[Values.Amount];});

			Console.WriteLine("UpdatePB2 {0} {1}", v.PB2Result[Values.Times], v.PB2Result[Values.Amount]);

			return 7;
		}
		
		// powerball + 3 balls, $100
		public int UpdatePB3(GUI g, Values v)
		{
			v.PB3Result[Values.Times]++;
			v.PB3Result[Values.Amount] += 100;
			Application.Invoke(delegate {g.PB3Wins = v.PB3Result[Values.Times];
				g.PB3Amount = v.PB3Result[Values.Amount];});

			Console.WriteLine("UpdatePB3 {0} {1}", v.PB3Result[Values.Times], v.PB3Result[Values.Amount]);

			return 100;
		}
		
		// powerball + 4 balls, $10,000
		public int UpdatePB4(GUI g, Values v)
		{
			v.PB4Result[Values.Times]++;
			v.PB4Result[Values.Amount] += 10000;
			Application.Invoke(delegate {g.PB4Wins = v.PB4Result[Values.Times];
				g.PB4Amount = v.PB4Result[Values.Amount];});

			Console.WriteLine("UpdatePB4 {0} {1}", v.PB4Result[Values.Times], v.PB4Result[Values.Amount]);

			return 10000;
		}
		
		public int UpdateJackpot()
		{
			//return Int32.Parse(eJackpot.Text);
			return 42;
		}
		
		// 3 balls match, $7
		public int Update3(GUI g, Values v)
		{
			v.Ball3Result[Values.Times]++;
			v.Ball3Result[Values.Amount] += 7;
			Application.Invoke(delegate{g.Ball3Wins = v.Ball3Result[Values.Times];
				g.Ball3Amount = v.Ball3Result[Values.Amount];});
			Console.WriteLine("Update3 {0} {1}", v.Ball3Result[Values.Times], v.Ball3Result[Values.Amount]);

			return 7;
		}
		
		public int Update4(GUI g, Values v)
		{
			v.Ball4Result[Values.Times]++;
			v.Ball4Result[Values.Amount] += 100;
			Application.Invoke(delegate{g.Ball4Wins = v.Ball4Result[Values.Times];
			                            g.Ball4Amount = v.Ball4Result[Values.Amount];});
			Console.WriteLine("Update4 {0} {1}", v.Ball4Result[Values.Times], v.Ball4Result[Values.Amount]);
			
			return 100;
		}
		
		public int Update5(GUI g, Values v)
		{
			v.Ball5Result[Values.Times]++;
			v.Ball5Result[Values.Amount] += 200000;
			Application.Invoke(delegate{g.Ball5Wins = v.Ball5Result[Values.Times];
			                            g.Ball5Amount = v.Ball5Result[Values.Amount];});
			Console.WriteLine("Update5 {0} {1}", v.Ball5Result[Values.Times], v.Ball5Result[Values.Amount]);
			
			return 200000;
		}

		Values values;
		
		public static void Main (string[] args)
		{
			new Powerball(args);
		}
		
		public Powerball(string[] args)
		{
			Application.Init();

			rnd = new R250((uint)DateTime.Now.Ticks);
			
			values = new Values(rnd);
			gui = new GUI(values);
			
			Application.Run();
			
		}
		
	}
}